{% extends 'base.html' %}
{% load article_tags %}
{% block title %}articles{% endblock %}
{% load static %}
{% block content %}
    <div class="row text-center vertical-middle-sm">
    <h1>阅读，丰富头脑，善化行为</h1>
    </div>

    <div class="container">
    <div class="col-md-8">
        {% for article in articles %}
            <div class="list-group">
            <a href="{{ article.get_url_path }}" class="list-group-item active">
                <h4 class="list-group-item-heading">{{ article.title }}</h4>
            </a>

            <p class="list-group-item-text">作者：
                <a href="{% url 'article:author_articles' article.author %}">{{ article.author }}</a>
            </p>

            <p class="list-group-item-text">概要：{{ article.body|slice:'30'|linebreaks }}</p>
            </div>
        {% endfor %}
    {% include 'paginator.html' %}
    </div>

    <div class="col-md-4">
        <div>
            {% if userinfo.photo %}
                <img class="img-circle" id="my_photo" src="{{ userinfo.photo | striptags }}"
                     style="width: 300px;" alt="">
            {% else %}
                <img src="{% static 'images/nuwton.jpg' %}" class="img-circle" style="width: 300px" alt="">
            {% endif %}
        </div>
        <div>
            <p>{{ user.username }}</p>
            <p>共发表文章{% user_total_articles user %}篇</p>
            {% if userinfo %}
                <p>{{ userinfo.company }}</p>
                <p>{{ userinfo.aboutme }}</p>
            {% else %}
                <p>这个作者太懒了，什么也没留下。</p>
            {% endif %}
        </div>
    </div>
    </div>
{% endblock %}